cmake_minimum_required(VERSION 3.10)

project (udp_video LANGUAGES C)
add_compile_options(-Wall -O2 -g)
set(CMAKE_BUILD_TYPE "Debug")

# 添加工程头文件
include_directories(./)

# 添加源文件
list(APPEND SOURCE_CODE
    ./main.c
	./argparse.c
	./socket_udp.c
	./media_buf.c
	./hisi_venc.c
)

# 添加海思sample源文件
list(APPEND HISI_SAMPLE_SOURCE
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/loadbmp.c

	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/loadbmp.h
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm.h

    # common 相关
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_2bpp_drawline.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_audio.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_isp.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_region.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_sys.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_venc.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_vi.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_vo.c
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/sample_comm_vpss.c

    # venc 相关
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/venc/sample_venc.c
    
    # sensor ISP 相关
    ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/src/core/hi_scene_setparam.c
    ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/src/core/hi_scene.c
    ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/src/sample/scene_loadparam.c
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/src/sample/scene_sample.c
    ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/tools/configaccess/src/hi_confaccess.c
    ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/tools/iniparser/src/dictionary.c
    ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/tools/iniparser/src/iniparser.c

    # 音频相关
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/audio/sample_audio.c
    
    # 支持aac
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/audio/adp/audio_aac_adp.c
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/audio/adp/audio_dl_adp.c
)

# 添加 hisi sdk 头文件
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/include/adapt)

# 添加 sample 头文件
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/common/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/tools/configaccess/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/scene_auto/tools/iniparser/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sample/audio/adp/)

# hisi sdk 内核动态库
list(APPEND HISI_KO_LIB
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_acodec.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_adc.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_adec.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_aenc.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_ai.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_aio.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_ao.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_base.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_chnl.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_h264e.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_h265e.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_isp.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_ive.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_jpege.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_pm.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_rc.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_rgn.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_sys.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_tde.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_vedu.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_venc.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_vgs.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_vi.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_vo.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_vpss.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi3516ev200_wdt.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi_cipher.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hifb.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi_mipi_rx.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi_osal.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/hi_user.ko
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/sys_config.ko
    
    # 扩展动态库，暂时用不到
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_adv7179.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_piris.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_pwm.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_sample_ist.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_sensor_i2c.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_sensor_spi.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_sil9024.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_ssp_ota5182.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_ssp_st7789.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/hi_tlv320aic31.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/ssp_st7796.ko
    # ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/ko/extdrv/tw28651.ko
)

# hisi sdk 动态库和静态库
list(APPEND HISI_SO_LIB
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaaccomm.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaaccomm.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacdec.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacdec.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacenc.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacenc.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacsbrdec.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacsbrdec.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacsbrenc.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libaacsbrenc.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libbcd.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libbcd.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libdnvqe.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libdnvqe.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiae.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiae.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiawb.a
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiawb_natura.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiawb_natura.so
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiawb.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhi_cipher.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhi_cipher.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hidehaze.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hidehaze.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hidrc.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hidrc.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiir_auto.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hiir_auto.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hildci.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/lib_hildci.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_AEC.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_AEC.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_AGC.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_AGC.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_ANR.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_ANR.so
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_common.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_EQ.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_EQ.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_HPF.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_HPF.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_record.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_record.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_RES.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libhive_RES.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libisp.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libisp.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libive.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libive.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libivp.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libivp.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libmd.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libmd.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libmpi.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libmpi.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libqr.a
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libsecurec.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libsecurec.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libsns_imx335.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libsns_imx335.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libtde.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libtde.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libupvqe.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libupvqe.so
	# ${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libVoiceEngine.a
	${CMAKE_CURRENT_SOURCE_DIR}/../../hisi_sdk/lib/libVoiceEngine.so
)

# 生成程序
add_executable(udp_video ${HISI_SAMPLE_SOURCE} ${SOURCE_CODE})

# 链接hisi库
target_link_libraries(udp_video ${HISI_KO_LIB} ${HISI_SO_LIB})

# 链接其他库
target_link_libraries(udp_video m pthread stdc++)
